﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace OpenLS.Spreadsheet.StandardAddIn
{
    class ColumnArrayValue: IArray
    {
        private readonly List<object> _row;

        public ColumnArrayValue(IEnumerable<object> rowObjects)
        {
            this._row = new List<object>(rowObjects);
        }
        public ColumnArrayValue(IEnumerable<double> rowObjects)
        {
            this._row = new List<object>();
            foreach (var rowObject in rowObjects)
            {
                _row.Add(rowObject);
            }
        }

        public IEnumerator<object> GetEnumerator()
        {
            throw new NotSupportedException();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public object this[int row, int column]
        {
            get
            {
                if (column >= this._row.Count)
                    return Errors.NaError;
                return this._row[column];
            }
        }

        public int RowCount
        {
            get { return 1; }
        }

        public int ColumnCount
        {
            get { return _row.Count; }
        }
    }
}